package com.example.nextstream.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.nextstream.dto.SessionInfo;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import com.example.nextstream.models.ClientSession;

import java.util.List;

@Component
public interface ClientSessionMapper extends BaseMapper<ClientSession> {
    @Select("SELECT\n" +
            "\tclient_session.session_id, \n" +
            "\t`user`.username as author_username, \n" +
            "\tassets_info.assets_protocol , \n"+
            "\tassets_info.assets_name\n" +
            "FROM\n" +
            "\tclient_session,\n" +
            "\t`user`,\n" +
            "\tassets_info\n" +
            "WHERE\n" +
            "\tclient_session.author_id = `user`.id  AND\n" +
            "\tclient_session.assets_id = assets_info.assets_id AND\n" +
            "\tclient_session.deleted = 0 AND\n" +
            "\t`user`.id = #{authorId}")
    public List<SessionInfo> getSessionInfo(Integer authorId);
}
